package cn.iocoder.yudao.module.call.mq.producer.taskcalleelistimport;

import cn.iocoder.yudao.module.call.mq.message.taskcalleelistimport.TaskCalleeListImportMessage;
import cn.iocoder.yudao.module.call.service.taskcalleelist.CallTaskCalleeListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 呼叫名单导入 Producer
 */
@Slf4j
@Component
public class TaskCalleeListImportProducer {

    @Resource
    private ApplicationContext applicationContext;

    @Resource

    private CallTaskCalleeListService callTaskCalleeListService;

    /**
     * 发送 {@link TaskCalleeListImportMessage} 消息
     */
    public void sendTaskCalleeListImportMessage(String path, Long listId, String taskId, Integer verify, Integer unique) {
        //标记呼叫名单为导入中
        callTaskCalleeListService.updateTaskCalleeListStatus(listId, 1);
        TaskCalleeListImportMessage message = new TaskCalleeListImportMessage()
                .setPath(path)
                .setTaskId(taskId)
                .setListId(listId)
                .setVerify(verify)
                .setUnique(unique);
        applicationContext.publishEvent(message);

    }

}
